/**
 * Enemy.java
 */

package rainingcatsdogs;

import javax.microedition.lcdui.Image;

/**
 * The Enemy class which holds an enemy that is falling from the top of the
 * screen
 */
public class Enemy extends MovableObject {

	/**
	 * This is the health that the enemy unit currently has.
	 */
	private int health;

	/**
	 * The damage inflicted by the enemy on the turret.
	 */
	private int turretDamage;

	/**
	 * The damage inflicted by the enemy on the terrain.
	 */
	private int terrainDamage;

	/**
	 * Construct the enemy object based on an image and a given health
	 * 
	 * @param explodeFrames
	 *            The number of frames it takes for the enemy to explode, once
	 *            destroyed
	 * @param image
	 *            The image of the enemy to use
	 * @param frameWidth
	 *            The width of one frame of the image
	 * @param frameHeight
	 *            The height of one frame of the image
	 * @param health
	 *            The health points of the enemy
	 * @param terrainDamage
	 *            The damage inflicted upon the terrain by the enemy
	 * @param turretDamage
	 *            The damaged inflicted upon the turret by the enemy
	 */
	public Enemy(int explodeFrames, Image image, int frameWidth,
			int frameHeight, int health, int terrainDamage, int turretDamage) {
		super(explodeFrames, image, frameWidth, frameHeight);
		this.health = health;
		this.terrainDamage = terrainDamage;
		this.turretDamage = turretDamage;
	}

	/**
	 * This reduces the current health of the enemy, if the health drop below 1
	 * then the enemy is destroyed.
	 * 
	 * @param damage
	 *            The amount of damage the enemy should be taking.
	 * @return Whether the enemy is destroyed
	 */
	public boolean reduceHealth(int damage) {
		this.health -= damage;
		if (this.health < 1) {
			this.destroy();
			return true;
		} else {
			return false;
		}
	}

	/**
	 * The damage taken by the turret if hit by enemy
	 * 
	 * @return the damage inflicted by the enemy on the turret
	 */
	public int getTurretDamage() {
		return turretDamage;
	}

	/**The damage taken by the terrain if hit by an enemy
	 * 
	 * 
	 * @return the damage inflicted by the enemy on the turret
	 */
	public int getTerrainDamage() {
		return terrainDamage;
	}

}
